#ifndef IGH_MASTER_H
#define IGH_MASTER_H

#include "EtherCATMaster.h"
#include <ecrt.h> // IGH EtherCAT库头文件

// IGH EtherCAT主站实现类
class IGHMaster : public EtherCATMaster {
private:
    // IGH相关成员变量
    ec_master_t *master;
    ec_master_state_t master_state;
    ec_domain_t *domain;
    ec_domain_state_t domain_state;
    uint8_t *domain_pd;
    ec_slave_config_t *slave_config;
    ec_slave_config_state_t slave_config_state;
    
    // 周期时间（纳秒）
    static const uint32_t PERIOD_NS = 1000000; // 1ms
    
    // 计数器，用于定期检查状态
    unsigned int counter;
    
public:
    IGHMaster();
    ~IGHMaster() override;
    
    // 实现抽象接口
    bool init(const std::string& ifname) override;
    bool configureSlaves() override;
    bool activate() override;
    bool receiveProcessData() override;
    bool sendProcessData() override;
    bool checkMasterState() override;
    bool checkDomainState() override;
    bool checkSlaveConfigState() override;
    void shutdown() override;
    void cyclicTask() override;
};

#endif // IGH_MASTER_H